<%@ page language="java" isELIgnored="false"
	contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib uri="/WEB-INF/tlds/authorizetag.tld" prefix="px"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Insert title here</title>
<!-- Bootstrap core CSS -->
<link href="/admin/public/bootstrap.min.css" title="" rel="stylesheet" />
<link rel="stylesheet" href="/admin/css/plugins/toastr/toastr.min.css" />
<!-- 时间控件样式 -->
<link
	href="/admin/css/plugins/datetimepicker/bootstrap-datetimepicker.min.css"
	rel="stylesheet" media="screen" />
<link href="/admin/public/animate.css" rel="stylesheet">
<link rel="stylesheet" href="/admin/css/plugins/toastr/toastr.min.css" />
<link href="/admin/font-awesome/css/font-awesome.min.css"
	rel="stylesheet" />
<link rel="stylesheet" href="/admin/public/inspinia.css" />
<link rel="stylesheet" href="/admin/css/templet_form.css" />
<link rel="stylesheet" type="text/css"
	href="${request.getContext }/admin/css/xcConfirm.css" />
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
	<script src="/admin/public/html5shiv.min.js"></script>
	<script src="/admin/public/respond.min.js"></script>
<![endif]-->
<style>
th.prev {
	background: url(/admin/img/dateleft.png) -3px !important;
}

th.next {
	background: url(/admin/img/dateright.png) -10px !important;
}

table a {
	color: #fff !important;
}
</style>
</head>
<body style="min-width: 1700px;overflow: auto;">
	<div id="wrapper" class="container">
		<!--标编辑-->
		<div id="biaobj" class=" wrapper wrapper-content animated fadeInRight">
			<h3>月卡订单列表</h3>
			<div class="right_box" id="right_box">
				<form action="/admin/Indent/monthCardList" id="sel" class="form-horizontal">
					<div class="form-group">
						<div class="col-lg-3 col-md-3 col-sm-3">
							<label class="col-lg-4 col-md-4 col-sm-4 control-label" for="">
								选择门店：</label>
							<div class="col-lg-7 col-md-7 col-sm-7 chosen-container chosen-container-single">
								<select class="select2_demo_1 form-control" name="shopId"
									id="shopId">
									<option value="">所有</option>
									<c:forEach items="${shopList }" var="item">
										<option value="${item.shopId }" <c:if test="${shopId eq item.shopId }">selected="selected" </c:if>>${item.shopName }</option>
									</c:forEach>
								</select>
							</div>
						</div>
						<div class="col-lg-3 col-md-3 col-sm-3">
							<label for="" class="col-lg-4 col-md-4 col-sm-4 control-label">
								卡片名称：</label>
							<div
								class="col-lg-7 col-md-7 col-sm-7 chosen-container chosen-container-single">
								<select class="select2_demo_1 form-control" name="cardId"
									id="cardId">
									<option value="">所有</option>
									<c:forEach items="${cardList }" var="item">
										<option value="${item.cardId }" <c:if test="${cardId eq item.cardId }">selected="selected" </c:if>>${item.cardName }</option>
									</c:forEach>
								</select>
							</div>
						</div>
						<div class="col-lg-4 col-md-4 col-sm-4">
							<label for="" class="col-lg-3 col-md-3 col-sm-3 control-label">购买时间：</label>
							<div class="col-md-4 col-lg-4 col-sm-4">
								<div class="date input-append form_date ymd_date"
									id="addtimeCalendar" style="float: left; margin-right: 5px;">
									<div class="input-group">
										<input class="form-control input-sm" type="text"
											name="startTime" id="startTime" value="${startTime}" > <span
											class="add-on input-group-addon"
											style="position: relative; left: -40px;"> <i
											class="fa fa-calendar" style="color: black;"></i>
										</span>
									</div>
								</div>
							</div>
							<span class="col-lg-1 col-md-1 col-sm-1"
								style="float: left; margin-top: 8px; position: relative; left: -40px;">—</span>
							<div class="col-md-4 col-lg-4 col-sm-4">
								<div class="date input-append form_date ymd_date"
									id="addtimeCalendar" style="float: left; margin-right: 5px;">
									<div class="input-group">
										<input class="form-control input-sm" type="text"
											name="endTime" id="endTime" value="${endTime}"> <span
											class="add-on input-group-addon"
											style="position: relative; left: -40px;"><i
											class="fa fa-calendar" style="color: black;"></i></span>
									</div>
								</div>
							</div>
						</div>
						<div class="col-lg-2 col-md-2 col-sm-2">
							<button style="width: 82px; height: 34px;" type="button"
							class="col-lg-3 btn btn-success" onclick="clearInput();">清空</button>
							<input type="submit"
								style="width: 82px; height: 34px; margin-left: 12px" value="搜索"
								class="col-lg-3 btn btn-success" />
						</div>
					</div>
					<div class="form-group">
						<button style="width: 82px; height: 34px;margin-left: 20px;" type="button"
						class="col-lg-3 btn btn-success" onclick="day();">今日</button>
						<button style="width: 82px; height: 34px;margin-left: 20px;" type="button"
						class="col-lg-3 btn btn-success" onclick="week();">最近七日</button>
						<button style="width: 82px; height: 34px;margin-left: 20px;" type="button"
						class="col-lg-3 btn btn-success" onclick="month();">本月</button>
					</div>
				</form>
			</div>
			<!--<button onclick="add_user()" style="margin-left:10px;" type="button" class="btn btn-success"> <i class="fa fa-plus"></i> 添加</button>-->
			</form>
			<!--表格部分-->
			<div><p>订单总数：${page.totalCount }</p></div>
			<div class="ibox-content">
						<div class="row">
							<div class="col-sm-12">
								<table class="table table-striped table-bordered table-hover dataTables-example">
									<thead>
										<tr>
											<!-- <th>门店</th> -->
											<th>卡片名称</th>
											<th>购买人</th>
											<th>联系电话</th>
											<th>是否会员</th>
											<th>订单金额</th>
											<th>实付金额</th>
											<th>优惠券</th>
											<th>支付方式</th>
											<th>购买时间</th>
											<th>过期时间</th>
											<!-- <th>剩余使用次数</th>
											<th>取消预约次数</th> -->
											<th>是否冻结</th>
											<th>是否退款</th>
											<th>操作</th>
										</tr>
									</thead>
									<tbody>
										<c:forEach items="${newmonthCardList }" var="item" varStatus="n">
											<tr>
												<td>${item.cardName }</td>
												<td>${item.userName }</td>
												<td>${item.telenumber }</td>
												<td>
													<c:if test="${empty(item.telenumber)}">游客</c:if>
													<c:if test="${!empty(item.telenumber)}">会员</c:if>
												</td>
												<td>${item.qian }元</td>
												<td>${item.sfMoney }元</td>
												<td>
													<c:if test="${empty(item.couponId)}">无</c:if>
													<c:if test="${!empty(item.couponId)}">
														<c:if test="${item.couponType==0 }">${item.discount }折	折扣券</c:if>
														<c:if test="${item.couponType==1 }">${item.price }元		代金券</c:if>
													</c:if>
												</td>
												<td>${item.payType }</td>
												<td>
													<fmt:formatDate type="time" value="${item.operationTime }" pattern="yyyy-MM-dd HH:mm:ss" />
												</td>
												<td>
													<span <c:if test="${date ge  item.invalidDate }">style="color:red;"</c:if>>
														<fmt:formatDate type="time" value="${item.invalidDate }" pattern="yyyy-MM-dd HH:mm:ss" />
													</span>
												</td>
												<%-- <td>${item.useNum }</td>
												<td>${item.num }</td> --%>
												<td>
													<c:if test="${item.isFreeze eq 0 }">
														正常
													</c:if>
													<c:if test="${item.isFreeze eq 1 }">
														<span style="color:red;">已冻结</span>
													</c:if>
												</td>
												<td>
													<c:if test="${item.isback==0 }">
														使用中
													</c:if>
													<c:if test="${item.isback==1 }">
														<span style="color:red;">已退款</span>
													</c:if>
												</td>
												<td>
													<c:if test="${item.isFreeze eq 1 && item.isback==0}">
													<a onclick="frozen(${item.userId },${item.usercardId })"
														class="up btn btn-primary btn-xs"><i class="fa fa-pencil"></i>解除冻结</a> 
													</c:if>
													<c:if test="${item.experience==null && item.isback==0 && item.isFreeze eq 0 }">
														<a onclick="tuikuan('${item.userId }','${item.payType }','${item.qian }','${item.usercardId }','${item.liushui }','${item.returnliushui }');"   class="btn btn-success btn-xs">退款</a>
													</c:if>
												</td>
											</tr>
										</c:forEach>
									</tbody>
								</table>
							</div>
						</div>
						<div class="row">
							<form action="" id="for" name="for" method="post">
								<input type="hidden" name="yehao" id="yin" value="1"> <input
									type="hidden" name="pagesize" id="tiaoshu"
									value="${page.pageSize }">
								<div class="fy">
									<span style="float: left;">每页条数：</span> <select
										style="width: 70px; float: left;"
										onchange="changeItem(this.value)" id="pagesize"
										name="pageSize">
										<option value="10" ${page.pageSize==10?'selected':'' }>10</option>
										<option value="20" ${page.pageSize==20?'selected':'' }>20</option>
										<option value="50" ${page.pageSize==50?'selected':'' }>50</option>
										<option value="100" ${page.pageSize==100?'selected':'' }>100</option>
										<option value="200" ${page.pageSize==200?'selected':'' }>200</option>
									</select>
									<div style="height: 27px;" class="col-sm-7">
										<div class="dataTables_paginate paging_simple_numbers"
											id="editable_paginate">
											<ul class="pagination pull-right" style="margin: -3px 0;">
												<li class="paginate_button previous" id="editable_previous">
													<a href="javascript:han(${page.pageNow-1 })"
													aria-controls="editable" data-dt-idx="0" tabindex="0">上一页</a>
												</li>
												<li class="paginate_button previous" id="editable_previous">
													<a aria-controls="editable" style="border: 0"
													data-dt-idx="0" tabindex="1"><input type="text"
														id="current"
														style="width: 32px; height: 19px; text-align: center;"
														value="${page.totalPageCount==0?0:page.pageNow}" /> /
														${page.totalPageCount }</a>
												</li>
												<li class="paginate_button previous" id="editable_previous">
													<a href="javascript:han(${page.pageNow+1 })"
													aria-controls="editable" data-dt-idx="0" tabindex="5">下一页</a>
													<a href="javascript:han($('#current').val())"
													aria-controls="editable" data-dt-idx="0" tabindex="5">跳转</a>
												</li>
											</ul>
										</div>
									</div>
									<div style="float: right;">总共${page.totalCount }条</div>
								</div>

							</form>
						</div>
					</div>
		</div>
	</div>
	</div>
	<iframe id="ifr" src="" frameborder="no" scrolling="no" width="780px"
		height="100%" allowtransparency="true"></iframe>
	<script src="/admin/public/jquery-1.11.3.js"></script>
	<script src="/admin/public/bootstrap.min.js" type="text/javascript"></script>
	<script src="/admin/js/plugins/lhgdialog/lhgdialog.js"></script>
	<!-- 弹出警示框 -->
	<script src="/admin/js/plugins/toastr/toastr.min.js"></script>
	<script src="/admin/js/new_page.js"></script>
	<!-- 弹出确认框 -->
	<script src="/admin/public/artDialog4.1.7/artDialog.js?skin=blue"></script>
	<script src="/admin/public/artDialog4.1.7/plugins/iframeTools.js"></script>
	<!-- 时间控件样式 -->
	<script src="/admin/js/Tab_swiper.js"></script>
	<script
		src="/admin/js/plugins/datetimepicker/bootstrap-datetimepicker.min.js"></script>
	<script
		src="/admin/js/plugins/datetimepicker/bootstrap-datetimepicker-update.min.js"></script>
	<script
		src="/admin/js/plugins/datetimepicker/bootstrap-datetimepicker.zh-CN.js"></script>
	<script src="${request.getContext }/admin/js/xcConfirm.js"
		type="text/javascript" charset="utf-8"></script>
	<script
		src="${request.getContext }/admin/js/plugins/lhgdialog/lhgdialog.js"></script>
	<script src="/admin/js/templet_form.js"></script>
	<script>
	//清空
	function clearInput(){
		$("#shopId").val('');
		$("#cardId").val('');
		$("#startTime").val('');
		$("#endTime").val('');
	}
	//获取当前时间
	function getNowFormatDate() {
	    var date = new Date();
	    var seperator1 = "-";
	    var seperator2 = ":";
	    var month = date.getMonth() + 1;
	    var strDate = date.getDate();
	    if (month >= 1 && month <= 9) {
	        month = "0" + month;
	    }
	    if (strDate >= 0 && strDate <= 9) {
	        strDate = "0" + strDate;
	    }
	    //yyyy-MM-dd HH:mm:ss
	    /* var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate
	            + " " + date.getHours() + seperator2 + date.getMinutes()
	            + seperator2 + date.getSeconds(); */
	    //yyyy-MM-dd
	    //获取今天
	    var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate;
	    //获取七天前
	    var date2 = new Date(currentdate);
	    date2.setDate(date2.getDate()-6);
	    var month2 = date2.getMonth() + 1;
	    var strDate2 = date2.getDate();
	    if (month2 >= 1 && month2 <= 9) {
	        month2 = "0" + month2;
	    }
	    if (strDate2 >= 0 && strDate2 <= 9) {
	        strDate2 = "0" + strDate2;
	    }
	    var currentdate2 = date2.getFullYear() + seperator1 + month2 + seperator1 + strDate2;
	    //获取本月初
	    var currentdate3 = date.getFullYear() + seperator1 + month + seperator1 + "01";        
	    return [currentdate,currentdate2,currentdate3]; 
	}
	function day(){
		var now = getNowFormatDate();
		$("#startTime").val(now[0]);
		$("#endTime").val(now[0]);
		$("#sel").submit();
	}
	function week(){
		var now = getNowFormatDate();	
		$("#startTime").val(now[1]);
		$("#endTime").val(now[0]);
		$("#sel").submit();
	}
	function month(){
		var now = getNowFormatDate();
		$("#startTime").val(now[2]);
		$("#endTime").val(now[0]);
		$("#sel").submit();
	}
	//分页
 	function han(pn){
 		document.getElementById("yin").value=pn;
 		var biao=document.getElementById("for");
 		document.for.action="/admin/Indent/monthCardList?shopId="+document.all.shopId.value+"&cardId="+document.all.cardId.value+"&startTime="+document.all.startTime.value+"&endTime="+document.all.endTime.value;
 		biao.submit();
 	}
 	function changeItem(size) {
 		document.getElementById("tiaoshu").value=size;
 		var biao=document.getElementById("for");
 		document.for.action="/admin/Indent/monthCardList?shopId="+document.all.shopId.value+"&cardId="+document.all.cardId.value+"&startTime="+document.all.startTime.value+"&endTime="+document.all.endTime.value;
 		biao.submit();
 	}
 	//取消冻结账户
	function frozen(userId,usercardId){
		window.wxc.xcConfirm("确定要取消冻结吗？", window.wxc.xcConfirm.typeEnum.confirm,{onOk:function(){ 
  			$.post("/admin/Member/frozen",{"userId":userId,"usercardId":usercardId},
  			function(data){
  				window.wxc.xcConfirm(data.msg, window.wxc.xcConfirm.typeEnum.info,
						{onOk:function(){window.location.href="/admin/Indent/monthCardList";}}
				)
  			});
  		}})
	}
	//退款
	function tuikuan(userId,payType,qian,usercardId,liushui,returnliushui){
		window.wxc.xcConfirm("确定退款吗?", window.wxc.xcConfirm.typeEnum.confirm,{onOk:function(){ 
			$.post("/admin/Member/tuikuan",{"userId":userId,"payType":payType,"qian":qian,"usercardId":usercardId,"liushui":liushui,"returnliushui":returnliushui},
		  			function(data){
		  				window.wxc.xcConfirm(data.msg, window.wxc.xcConfirm.typeEnum.info,
								{onOk:function(){window.location.href="/admin/Indent/monthCardList";}}
						)
		  			});
		}})
	}
</script>
</body>
</html>
